﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;


/// <summary>
/// Summary description for sign_up
/// </summary>
public class sign_up
{
    public static bool Register(string username, string password, string email, string question, string answer)
    {

        using (SWE2Entities db = new SWE2Entities())
        {

            int number;
            username = username.Replace(" ", "");
            password = password.Replace(" ", "");
            email = email.Replace(" ", "");

            bool result1 = Int32.TryParse(username, out number);

            bool result2 = Int32.TryParse(password, out number);

            bool result3 = Int32.TryParse(email, out number);



            UserInfo_Table st = new UserInfo_Table();
            if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(email) || string.IsNullOrEmpty(question) || string.IsNullOrEmpty(answer))
            {
                return false;
            }
            else if (result1 || result2 || result3)
            {
                return false;
            }
            else
                try
                {
                    st.Username = username;
                    st.Password = password;
                    st.E_mail = email;
                    st.Secret_Q = question;
                    st.Secret_Ans = answer;
                    db.UserInfo_Table.Add(st);
                    db.SaveChanges();
                    return true;

                }
                catch
                {
                    return false;
                }
            
           

        }


    }



}